<?php
// -----------------------------------------------------------------------------
// include
// -----------------------------------------------------------------------------

include "../config/config.php";
include "../auth.php";
include "../DBManager.php";

// -----------------------------------------------------------------------------
// 访问设置
// -----------------------------------------------------------------------------

if (!isset($_GET["id"])) {
    exit("需要传入有效的参数！");
}

$id = $_GET["id"];

// -----------------------------------------------------------------------------
// 数据库相关设置
// -----------------------------------------------------------------------------

$dbPath = "../" . $dbPath; // 不加这行语句的话会报错，提示找不到对应路径
$db = new DBManager("sqlite:" . $dbPath);

// -----------------------------------------------------------------------------

if (!$db->goalExist($id)) {
    exit("指定的目标不存在！");
}

try {
    $db->deleteGoal($id);
    echo "删除成功！";
} catch (Exception $e) {
    echo "删除失败！详情如下：";
    echo "<br />";
    echo $e->getMessage();
}
